fun Int.isPrime():Boolean {
    (2 until this).map {
        if (this%it == 0) {
            return false
        }
    }
    return true
}

fun main() {
    //找到0~5000里面的1000个素数
    val list = (1..5000).toList().filter { it.isPrime() }.take(1000)
    println(list)
    println(list.size)

    val oneThousandPrimes = generateSequence(2) { value ->
        value + 1
    }.filter { it.isPrime() }.take(1000)
    println(oneThousandPrimes.toList().size)
}